package Forms;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Grades_Add.java
 *
 * Created on Jan 15, 2013, 10:52:49 PM
 */


//import java.rmi.RemoteException;
//import java.util.logging.Level;
//import java.util.logging.Logger;
//import javax.swing.JFrame;
//import Classes.*;
//import java.awt.Color;
//import java.awt.event.KeyEvent;
//import java.rmi.registry.LocateRegistry;
//import java.rmi.registry.Registry;
//import java.text.DecimalFormat;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.HashSet;
//import java.util.List;
//import java.util.Set;
//import javax.swing.JOptionPane;
//import javax.swing.table.DefaultTableModel;
/**
 *
 * @author Owner
 */
public class GradesS_Manage extends javax.swing.JFrame {
//    static MInterface mi;
//    String port;
//    _Login l = new _Login();
//    
//    static User cUser;
//    ArrayList<Object> list;
//    ArrayList<Grades> gradeManage;   
//    ArrayList<Object> gradeList1 = null;
//    ArrayList<Object> gradeList2 = null;
//    ArrayList<Object> gradeList3 = null;
//    ArrayList<Object> attendanceList2 = null;
//    ArrayList<Object> attendanceList22 = null;
//    ArrayList<Object> grademanage5 = null;
//    ArrayList<Object> grademanage6 = null;
//    ArrayList<Object> subjects = null;
//    ArrayList<Object> aqw1 = null;
//    ArrayList<Grades1> a1000 = null;
//    List<String> testing = null;
//    List<String> testing1 = null;
//    DefaultTableModel dtm1;
//    Grades1 viewGrades = null;
//    String a= null;
//    String a1= null;
//    String a2= null;
//    String a3= null;
//    String a4= null;
//    String a5= null;
//    String a6= null;
//    String a7= null;
//    String a9 = null;
//    String a44= null;
//    String a99 = null;
//    String a100 = null;
//    String value =null;
//    String asd2 = null;
//    String val2 = null;
//    String val = null;
//    String val33 = null;
//    String abe = null;
//    String abe2 = null;
//    String abe3 = null;
//    String abe4 = null;
//    int aabe;
//    int aabe2;
//    int aabe3;
//    int aabe4;
//    int ab;
//    int ab1;
//    int ab2;
//    int ab3;
//    int a8 =0;
//    int a11;
//    int a12;
//    int a13;
//    int a14;
//    int aqwe1;
//    int a444;
//    String aqe;
//    String userID;
//    String usertID;
//    String stuID;
//    String abez = null;
//    String abe2z = null;
//    String abe3z = null;
//    int aabez;
//    int aabe2z;
//    int aabe3z;
//    String getsyname;
    public GradesS_Manage(/*MInterface i, User u*/) {
       // cUser = u;
//        initComponents();   
        this.setLocationRelativeTo(getRootPane());
////        mi = i;
////        port = l.serverAdd;
////        
////        try {
////            userID = u.getID();
////            usertID = u.getType();
////            
////            saveB.setVisible(false);
////            editB.setVisible(false);
////            clearB.setVisible(false);
////            genAveTF.setEnabled(false);
////            saveAveB.setEnabled(false);
////            jLabel6.setVisible(false);
////            jTextField7.setVisible(false);
////            jButton1.setEnabled(false);
////            usernameL.setText(u.getName());
////            timeL.setText(mi.getCurrentTime());
////            dateL.setText(mi.getCurrentDate());
////                                  
////            String sy = null;
////            if (mi.getCurrentDate().compareTo((mi.getEndSy(mi.getCurrentDate()))) > 0) {
////                sy = mi.getToday() + "-" + mi.getNext();
////            } else if (mi.getCurrentDate().compareTo((mi.getEndSy(mi.getCurrentDate()))) < 0) {
////                sy = mi.getPast() + "-" + mi.getToday();              
////            }
////            if(usertID.matches("Adviser")){
////                list = mi.getList1("gradeManage22", userID);
////            ArrayList<Grades1> s = new ArrayList<Grades1>();
////            for(int x = 0; x < list.size(); x++) {
////            s.add((Grades1) list.get(x));
////            
////            }
////            DefaultTableModel dtm = new DefaultTableModel(new String[] {gaGradeTbl1.getColumnName(0), gaGradeTbl1.getColumnName(1), gaGradeTbl1.getColumnName(2), gaGradeTbl1.getColumnName(3), gaGradeTbl1.getColumnName(4), gaGradeTbl1.getColumnName(5)}, 0);
////            gaGradeTbl1.setModel(dtm);
////            for(int x = 0; x < s.size(); x++) {
////                dtm.insertRow(x, new Object[] {s.get(x).getidno(),s.get(x).getname(), s.get(x).getclasslevel(), s.get(x).getsection(),  s.get(x).getsy(), s.get(x).getcname()});
////            
////            }
////            }else if(usertID.matches("Administrator")){
////            list = mi.getList("gradeManage");
////            ArrayList<Grades1> s = new ArrayList<Grades1>();
////            for(int x = 0; x < list.size(); x++) {
////                Grades1 a = (Grades1) list.get(x);
////                //System.out.println(list.get(x) + " | " + sy);
////                if(a.getsy().equals(sy)) s.add((Grades1) list.get(x));
////            
////            }
////            DefaultTableModel dtm = new DefaultTableModel(new String[] {gaGradeTbl1.getColumnName(0), gaGradeTbl1.getColumnName(1), gaGradeTbl1.getColumnName(2), gaGradeTbl1.getColumnName(3), gaGradeTbl1.getColumnName(4), gaGradeTbl1.getColumnName(5)}, 0);
////            gaGradeTbl1.setModel(dtm);
////            for(int x = 0; x < s.size(); x++) {
////                dtm.insertRow(x, new Object[] {s.get(x).getidno(),s.get(x).getname(), s.get(x).getclasslevel(), s.get(x).getsection(),  s.get(x).getsy(), s.get(x).getcname()});
////           
////            }
////            }
////         
////                     
////        } catch (Exception e) {
////            e.printStackTrace();
////        }
    }
////   
////
////    /** This method is called from within the constructor to
////     * initialize the form.
////     * WARNING: Do NOT modify this code. The content of this method is
////     * always regenerated by the Form Editor.
////     */
////   
        /*@SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        bannerL = new javax.swing.JLabel();
        jScrollPane48 = new javax.swing.JScrollPane();
        gaGradeTbl = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int colIndex){
                return false;
            }
        };
        jButton3 = new javax.swing.JButton();
        jScrollPane49 = new javax.swing.JScrollPane();
        gaGradeTbl1 = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int colIndex){
                return false;
            }
        };
        jButton6 = new javax.swing.JButton();
        searchT = new javax.swing.JTextField();
        saveAveB = new javax.swing.JButton();
        genAveTF = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        dateL = new javax.swing.JLabel();
        timeL = new javax.swing.JLabel();
        logoutB = new javax.swing.JButton();
        usernameL = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        currFld10 = new javax.swing.JLabel();
        jLabel78 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Grades Management");

        bannerL.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Resources/banner.jpg"))); // NOI18N
        bannerL.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jScrollPane48.setBackground(new java.awt.Color(255, 255, 255));

        gaGradeTbl.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        gaGradeTbl.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Subject", "1st Quarter", "2nd Quarter", "3rd Quarter", "4th Quarter", "Average"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        gaGradeTbl.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                gaGradeTblMouseClicked(evt);
            }
        });
        jScrollPane48.setViewportView(gaGradeTbl);

        jButton3.setText("Cancel");
        jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton3MouseClicked(evt);
            }
        });

        jScrollPane49.setBackground(new java.awt.Color(255, 255, 255));

        gaGradeTbl1.setAutoCreateRowSorter(true);
        gaGradeTbl1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        gaGradeTbl1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "ID Number", "Student", "Section", "School Year", "Class Level", "Curriculum Name"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        gaGradeTbl1.setSurrendersFocusOnKeystroke(true);
        gaGradeTbl1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                gaGradeTbl1MouseClicked(evt);
            }
        });
        jScrollPane49.setViewportView(gaGradeTbl1);

        jButton6.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jButton6.setText("Search");
        jButton6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton6MouseClicked(evt);
            }
        });

        searchT.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        searchT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                searchTMouseClicked(evt);
            }
        });
        searchT.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                searchTKeyTyped(evt);
            }
        });

        saveAveB.setText("Save");
        saveAveB.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                saveAveBMouseClicked(evt);
            }
        });

        genAveTF.setEnabled(false);

        jLabel7.setText("Gen. Average:");

        jButton1.setText("Compute");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        dateL.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        dateL.setText("mm/dd/yyyy");

        timeL.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        timeL.setText("hh:mm am/pm");

        logoutB.setText("Logout");
        logoutB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logoutBActionPerformed(evt);
            }
        });

        usernameL.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        usernameL.setText("username");

        jSeparator1.setForeground(new java.awt.Color(0, 0, 0));

        currFld10.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        currFld10.setText("0000");

        jLabel78.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel78.setText("No. of Entries:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator1)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(dateL)
                        .addGap(46, 46, 46)
                        .addComponent(timeL)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(usernameL)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(logoutB)
                        .addGap(24, 24, 24))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(searchT)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton6))
                            .addComponent(jScrollPane49)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel78)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(currFld10)
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jScrollPane48)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(genAveTF, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton1)
                                .addGap(6, 6, 6)
                                .addComponent(saveAveB)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButton3))))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(bannerL)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(bannerL, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(logoutB, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(usernameL)
                    .addComponent(dateL)
                    .addComponent(timeL))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(searchT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane48, javax.swing.GroupLayout.DEFAULT_SIZE, 448, Short.MAX_VALUE)
                    .addComponent(jScrollPane49))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(saveAveB)
                    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jButton1)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel78)
                                .addComponent(currFld10))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(genAveTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel7)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton3MouseClicked
        this.setVisible(false);
}//GEN-LAST:event_jButton3MouseClicked

    private void jButton6MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton6MouseClicked
//       try {
//            list = mi.getList("gradeManage");
//            ArrayList<Grades1> s = new ArrayList<Grades1>();
//            String str = searchT.getText().toLowerCase();
//            for(int x = 0; x < list.size(); x++) {
//                Grades1 ss = (Grades1) list.get(x);
//                if(ss.getidno().toLowerCase().contains(str) || ss.getname().toLowerCase().contains(str) || ss.getclasslevel().toLowerCase().contains(str) || ss.getsection().toLowerCase().contains(str) || ss.getsy().toLowerCase().contains(str) || ss.getcname().toLowerCase().contains(str)) {
//                    s.add(ss);
//                }
//            }
//
//            jLabel4.setText(s.size() + "");
//            DefaultTableModel dtm = new DefaultTableModel(new String[] {gaGradeTbl1.getColumnName(0), gaGradeTbl1.getColumnName(1), gaGradeTbl1.getColumnName(2), gaGradeTbl1.getColumnName(3), gaGradeTbl1.getColumnName(4), gaGradeTbl1.getColumnName(4)}, 0);
//            gaGradeTbl1.setModel(dtm);
//            for(int x = 0; x < s.size(); x++) {
//                dtm.insertRow(x, new Object[] {s.get(x).getidno(),s.get(x).getname(), s.get(x).getclasslevel(), s.get(x).getsection(),  s.get(x).getsy(), s.get(x).getcname()});
//            }       
//        } catch(Exception e) {
//            e.printStackTrace();
//        }
    }//GEN-LAST:event_jButton6MouseClicked

    private void gaGradeTbl1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_gaGradeTbl1MouseClicked
//           jComboBox1.setEnabled(true);
//           editB.setVisible(false);
//           clearB.setVisible(false);
//           saveB.setVisible(true);
//           jTextField2.setText("");
//        jTextField3.setText("");
//        jTextField4.setText("");
//        jTextField5.setText("");
//                 
//        
//        if(evt.getClickCount() == 2) {
//               
//            int x = gaGradeTbl1.getSelectedColumn();
//            while(x != 0) {
//                x--;
//            }
//            int y = gaGradeTbl1.getSelectedRow();
//            val = (String) gaGradeTbl1.getValueAt(y, x);
//            val2 = (String) gaGradeTbl1.getValueAt(y, 4);
//            val33 = (String) gaGradeTbl1.getValueAt(y, 5);
//            getsyname = (String) gaGradeTbl1.getValueAt(y, 3);
//            
//
//            jComboBox1.removeAllItems();    
//            
//            try {  
////                 attendanceList2 = mi.getList1("attendanceManage3", val);
////                 ArrayList<Attendance> uu2 = new ArrayList<Attendance>();
////                 for(int x2 = 0; x2 < attendanceList2.size(); x2++) {
////                 uu2.add((Attendance) attendanceList2.get(x2));
////                 a6 = uu2.get(x2).getstuID();
////
////            }
//                  attendanceList2 = mi.getList2("attendanceManage3", val, getsyname);
//                 ArrayList<Attendance> uu2 = new ArrayList<Attendance>();
//                 for(int x2 = 0; x2 < attendanceList2.size(); x2++) {
//                 uu2.add((Attendance) attendanceList2.get(x2));
//                 a6 = uu2.get(x2).getstuID();
//
//            }
//                 
//                
//                
//                 attendanceList2 = mi.getList1("gradeManage4", a6);
//                 ArrayList<Grades> uu4 = new ArrayList<Grades>();
//                 for(int x4 = 0; x4 < attendanceList2.size(); x4++) {
//                 uu4.add((Grades) attendanceList2.get(x4));
//                 abe = uu4.get(x4).getstuID();
//                 abe2 = uu4.get(x4).getsyID();
//                 abe3 = uu4.get(x4).getclassID();
//                 aabe = Integer.parseInt(abe);
//                 aabe2 = Integer.parseInt(abe2);
//                 aabe3 = Integer.parseInt(abe3);
//                 }
////                 System.out.println(val);
////                 System.out.println(abe2); 
//                 
//                 attendanceList22 = mi.getList2("gradeManage44", val,abe2);
//                 ArrayList<Grades> uu14 = new ArrayList<Grades>();
//                 for(int x14 = 0; x14 < attendanceList22.size(); x14++) {
//                 uu14.add((Grades) attendanceList22.get(x14));
//                 abez = uu14.get(x14).getstuID();
//                 abe2z = uu14.get(x14).getsyID();
//                 abe3z = uu14.get(x14).getclassID();
//                 aabez = Integer.parseInt(abez);
//                 aabe2z = Integer.parseInt(abe2z);
//                 aabe3z = Integer.parseInt(abe3z);
//                 }
//                 
////                 System.out.println(abez);
////                 System.out.println(abe2z);  
////                 gradeList1 = mi.getList1("gradeManage2", val);
////                 ArrayList<Grades1> uu1 = new ArrayList<Grades1>();
////                 for(int x1 = 0; x1 < gradeList1.size(); x1++) {
////                 uu1.add((Grades1) gradeList1.get(x1));
////            }
//                 
//                 gradeList1 = mi.getList2("gradeManage222", abez, abe2z);
//                 ArrayList<Grades1> uu1 = new ArrayList<Grades1>();
//                 for(int x1 = 0; x1 < gradeList1.size(); x1++) {
//                 uu1.add((Grades1) gradeList1.get(x1));
//                 
//            }
//                 
//                subjects = mi.getList2("subjectManage", val2, val33);
//                ArrayList<Subject> s12 = new ArrayList<Subject>();   
//                for(int x12 = 0; x12 < subjects.size(); x12++) {
//                s12.add((Subject) subjects.get(x12));                
//                asd2 = s12.get(x12).getSubjName();
//                a9 = s12.get(x12).getsubID();
//                
//                jComboBox1.addItem(asd2);   
//            }
//                
//             System.out.println(abe2);   
//                
////                subjects = mi.getList1("subjectManage", val2);
////                ArrayList<Subject> s12 = new ArrayList<Subject>();   
////                for(int x12 = 0; x12 < subjects.size(); x12++) {
////                s12.add((Subject) subjects.get(x12));                
////                asd2 = s12.get(x12).getSubjName();
////                a9 = s12.get(x12).getsubID();
////                jComboBox1.addItem(asd2);
////            }
//                
//                
//                 grademanage5 = mi.getList1("grademanage5", val);
//                 ArrayList<Grades1> uu5 = new ArrayList<Grades1>();
//                 for(int x5 = 0; x5 < grademanage5.size(); x5++) {
//                 uu5.add((Grades1) grademanage5.get(x5));
//                 a99 = uu5.get(x5).gettotave();
//                
//            }
//                 
////                 grademanage6 = mi.getList1("grademanage6", val);
////                 ArrayList<Grades1> uu6 = new ArrayList<Grades1>();
////                 for(int x6 = 0; x6 < grademanage6.size(); x6++) {
////                 uu6.add((Grades1) grademanage6.get(x6));
////                 a100 = uu6.get(x6).getave();
////                 System.out.println(a100);
////                
////            }
//                 
//                 
//              
//                
//                 
//                 dtm1 = new DefaultTableModel(new String[] {gaGradeTbl.getColumnName(0), gaGradeTbl.getColumnName(1), gaGradeTbl.getColumnName(2), gaGradeTbl.getColumnName(3), gaGradeTbl.getColumnName(4), gaGradeTbl.getColumnName(5)},   0);
//                 gaGradeTbl.setModel(dtm1);
//                 
//                 for(int x1 = 0; x1 < uu1.size(); x1++) {
//                 dtm1.insertRow(x1, new Object[] {uu1.get(x1).getsubject(), uu1.get(x1).getfirst(), uu1.get(x1).getsecond(),uu1.get(x1).getthird(), uu1.get(x1).getfourth(), uu1.get(x1).getave()});
//                // a6 = uu1.get(x1).getstuID();
//                 a7= uu1.get(x1).getsubID();
//
//                 jComboBox1.removeItem(uu1.get(x1).getsubject());
//                 
//                 }  
//             
//            if(jComboBox1.getSelectedItem() == null){
//            genAveTF.setEnabled(true);
//            jComboBox1.setEnabled(false);
//            jTextField2.setEnabled(false);
//            jTextField3.setEnabled(false);
//            jTextField4.setEnabled(false);
//            jTextField5.setEnabled(false);
//            jTextField7.setEnabled(false);
//            saveB.setEnabled(false);
//            saveAveB.setEnabled(true);
//            jButton1.setEnabled(true);
//            }else{
//            genAveTF.setEnabled(false);
//            jComboBox1.setEnabled(true);
//            jTextField2.setEnabled(true);
//            jTextField3.setEnabled(true);
//            jTextField4.setEnabled(true);
//            jTextField5.setEnabled(true);
//            jTextField7.setEnabled(true);
//            saveB.setEnabled(true);
//            saveAveB.setEnabled(false);
//            jButton1.setEnabled(false);
//            }
//           
//           
//                 
//            }catch (Exception e) {
//                JOptionPane.showMessageDialog(null, e.getMessage());
//                System.out.println(e);
//            }
//           
//        }
    }//GEN-LAST:event_gaGradeTbl1MouseClicked

    private void gaGradeTblMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_gaGradeTblMouseClicked
           
//        if(evt.getClickCount() == 2) {
//             jComboBox1.removeAllItems();
//            editB.setVisible(true);
//            clearB.setVisible(true);
//            saveB.setVisible(false);
//            jTextField2.setEnabled(true);
//            jTextField3.setEnabled(true);
//            jTextField4.setEnabled(true);
//            jTextField5.setEnabled(true);
//            int x = gaGradeTbl.getSelectedColumn();
//            while(x != 0) {
//                x--;
//            }
//            
//            int y = gaGradeTbl .getSelectedRow();
//            String val1 = (String) gaGradeTbl.getValueAt(y, x);
//            String val2 = (String) gaGradeTbl.getValueAt(y, 1);
//            String val3 = (String) gaGradeTbl.getValueAt(y, 2);
//            String val4 = (String) gaGradeTbl.getValueAt(y, 3);
//            String val5 = (String) gaGradeTbl.getValueAt(y, 4);
//            String val6 = (String) gaGradeTbl.getValueAt(y, 5);
//     
//           
//            
//            jComboBox1.addItem(val1);
//            jComboBox1.setEnabled(false);
//            try {  
//    
//             
//             jPanel1.setVisible(true);
//             editB.setVisible(true);
//             clearB.setVisible(true);
//             jButton3.setVisible(true);
//             
//             
//             jTextField2.setText(val2);
//             jTextField3.setText(val3);
//             jTextField4.setText(val4);
//             jTextField5.setText(val5);
//             jTextField7.setText(val6); 
//            }catch (Exception e) {
//                System.out.println(e);
//                JOptionPane.showMessageDialog(null, e.getMessage());
//                
//            }    
//        }
    }//GEN-LAST:event_gaGradeTblMouseClicked

    private void searchTMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_searchTMouseClicked
//        searchT.setText("");
//        searchT.setForeground(Color.black);
    }//GEN-LAST:event_searchTMouseClicked

    private void saveAveBMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saveAveBMouseClicked
//        String genA = genAveTF.getText().trim();
//        double genA1 = Double.parseDouble(genA);
//        DecimalFormat df = new DecimalFormat("#.##");
//        String genA2 = df.format(genA1);  
////        int adad = 0;
////        int t2=0;
////        String t4 = null;
//        try{   
////              testing = new ArrayList<String>();
////            for(int t1 = 0;t1 < 74;t1++){
////             t2 = t2+1;
////             
////             t4 = String.valueOf(t2);
////             testing.add(t4);
////             
////         }
////            
////         
////         a1000 = new ArrayList<Grades1>();
////         testing1 = new ArrayList<String>();
////         for(int x111 = 0; x111 < gradeList1.size(); x111++) {
////         a1000.add((Grades1) gradeList1.get(x111));
////         a100 = a1000.get(x111).getave();
////         adad = Integer.parseInt(a100);
////         testing1.add(a100);
////         
////         }
////         System.out.println(testing1);
////         System.out.println(testing);
////         
////         boolean contains = false;
////        for(int z = 0; z < testing.size(); z++){
////          aqe = testing.get(z).toString();
////          if(testing1.get(z).equals(aqe)){
////              contains = true;
////          }
////        }
////        
////         if(contains = true){
////             JOptionPane.showMessageDialog(null, "Error", "Error", 0);
////         }else if (contains = false) {
////         
////            mi.addgenAve(genA1, aabe, aabe3, aabe2, cUser);
////            JOptionPane.showMessageDialog(null, "GenAve Successfully Added", "OK", 1);
////         
////         }
//       
//            mi.addgenAve(genA2, aabe, aabe3, aabe2, cUser);
//            JOptionPane.showMessageDialog(null, "GenAve Successfully Added", "OK", 1);
//         
//       
////         if(contains == true){
////           JOptionPane.showMessageDialog(null, "Student has a grade below 75 he/she should repeat", "Error", 0);
////             
////           }else  { 
////            mi.addgenAve(genA1, aabe, aabe3, aabe2, cUser);
////            JOptionPane.showMessageDialog(null, "GenAve Successfully Added", "OK", 1);
////               
////           }
////         
//          
//         
//         
//            
//      
//        }catch(Exception e){
//            
//            System.out.println(e);
//        }
//        
    }//GEN-LAST:event_saveAveBMouseClicked

    private void searchTKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_searchTKeyTyped
        // TODO add your handling code here:
//        String s = "[a-zA-Z0-9\\._\\-]{3,}";
//        char c = evt.getKeyChar();
//    
//        if(c == KeyEvent.VK_SPACE) {
//            if(searchT.getText().isEmpty()) {
//                evt.consume();
//                JOptionPane.showMessageDialog (null, "Space bar not allowed as first character.", "Error", JOptionPane.ERROR_MESSAGE);
//            }
//    }
    
    
        
    }//GEN-LAST:event_searchTKeyTyped

    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
      //  genAveTF.setText(a99);
    }//GEN-LAST:event_jButton1MouseClicked

    private void logoutBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutBActionPerformed
//        int x = JOptionPane.showConfirmDialog(null,"Are you sure you want to logout already?","Alert!",JOptionPane.YES_NO_OPTION);
//        if(x == JOptionPane.YES_OPTION){
//            try {
//                mi.logout(cUser.getUsername());
//                this.setVisible(false);
//                new _Login().setVisible(true);
//            } catch(Exception e) {
//                e.printStackTrace();
//            }
//        }
}//GEN-LAST:event_logoutBActionPerformed

//GEN-FIRST:event_jButton1ActionPerformed
     * private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-HEADEREND:event_jButton1ActionPerformed
//
     * TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed

//    public void ref(){
//   
//           
//               
//            int x = gaGradeTbl1.getSelectedColumn();
//            while(x != 0) {
//                x--;
//            }
//            int y = gaGradeTbl1.getSelectedRow();
//            val = (String) gaGradeTbl1.getValueAt(y, x);
//            val2 = (String) gaGradeTbl1.getValueAt(y, 4);
//            val33 = (String) gaGradeTbl1.getValueAt(y, 5);
//            getsyname = (String) gaGradeTbl1.getValueAt(y, 3);
//            
//
//            jComboBox1.removeAllItems();    
//            
//            try {  
////                 attendanceList2 = mi.getList1("attendanceManage3", val);
////                 ArrayList<Attendance> uu2 = new ArrayList<Attendance>();
////                 for(int x2 = 0; x2 < attendanceList2.size(); x2++) {
////                 uu2.add((Attendance) attendanceList2.get(x2));
////                 a6 = uu2.get(x2).getstuID();
////
////            }
//                  attendanceList2 = mi.getList2("attendanceManage3", val, getsyname);
//                 ArrayList<Attendance> uu2 = new ArrayList<Attendance>();
//                 for(int x2 = 0; x2 < attendanceList2.size(); x2++) {
//                 uu2.add((Attendance) attendanceList2.get(x2));
//                 a6 = uu2.get(x2).getstuID();
//
//            }
//                 
//                
//                
//                 attendanceList2 = mi.getList1("gradeManage4", a6);
//                 ArrayList<Grades> uu4 = new ArrayList<Grades>();
//                 for(int x4 = 0; x4 < attendanceList2.size(); x4++) {
//                 uu4.add((Grades) attendanceList2.get(x4));
//                 abe = uu4.get(x4).getstuID();
//                 abe2 = uu4.get(x4).getsyID();
//                 abe3 = uu4.get(x4).getclassID();
//                 aabe = Integer.parseInt(abe);
//                 aabe2 = Integer.parseInt(abe2);
//                 aabe3 = Integer.parseInt(abe3);
//                 }
////                 System.out.println(val);
////                 System.out.println(abe2); 
//                 
//                 attendanceList22 = mi.getList2("gradeManage44", val,abe2);
//                 ArrayList<Grades> uu14 = new ArrayList<Grades>();
//                 for(int x14 = 0; x14 < attendanceList22.size(); x14++) {
//                 uu14.add((Grades) attendanceList22.get(x14));
//                 abez = uu14.get(x14).getstuID();
//                 abe2z = uu14.get(x14).getsyID();
//                 abe3z = uu14.get(x14).getclassID();
//                 aabez = Integer.parseInt(abez);
//                 aabe2z = Integer.parseInt(abe2z);
//                 aabe3z = Integer.parseInt(abe3z);
//                 }
//                 
////                 System.out.println(abez);
////                 System.out.println(abe2z);  
////                 gradeList1 = mi.getList1("gradeManage2", val);
////                 ArrayList<Grades1> uu1 = new ArrayList<Grades1>();
////                 for(int x1 = 0; x1 < gradeList1.size(); x1++) {
////                 uu1.add((Grades1) gradeList1.get(x1));
////            }
//                 
//                 gradeList1 = mi.getList2("gradeManage222", abez, abe2z);
//                 ArrayList<Grades1> uu1 = new ArrayList<Grades1>();
//                 for(int x1 = 0; x1 < gradeList1.size(); x1++) {
//                 uu1.add((Grades1) gradeList1.get(x1));
//                 
//            }
//                 
//                subjects = mi.getList2("subjectManage", val2, val33);
//                ArrayList<Subject> s12 = new ArrayList<Subject>();   
//                for(int x12 = 0; x12 < subjects.size(); x12++) {
//                s12.add((Subject) subjects.get(x12));                
//                asd2 = s12.get(x12).getSubjName();
//                a9 = s12.get(x12).getsubID();
//                jComboBox1.addItem(asd2);   
//            }
//                
////                subjects = mi.getList1("subjectManage", val2);
////                ArrayList<Subject> s12 = new ArrayList<Subject>();   
////                for(int x12 = 0; x12 < subjects.size(); x12++) {
////                s12.add((Subject) subjects.get(x12));                
////                asd2 = s12.get(x12).getSubjName();
////                a9 = s12.get(x12).getsubID();
////                jComboBox1.addItem(asd2);
////            }
//                
//                
//                 grademanage5 = mi.getList1("grademanage5", val);
//                 ArrayList<Grades1> uu5 = new ArrayList<Grades1>();
//                 for(int x5 = 0; x5 < grademanage5.size(); x5++) {
//                 uu5.add((Grades1) grademanage5.get(x5));
//                 a99 = uu5.get(x5).gettotave();
//                 
//                
//            }
//                 
//                
//              
//                
//                 
//                 dtm1 = new DefaultTableModel(new String[] {gaGradeTbl.getColumnName(0), gaGradeTbl.getColumnName(1), gaGradeTbl.getColumnName(2), gaGradeTbl.getColumnName(3), gaGradeTbl.getColumnName(4), gaGradeTbl.getColumnName(5)},   0);
//                 gaGradeTbl.setModel(dtm1);
//                 
//                 for(int x1 = 0; x1 < uu1.size(); x1++) {
//                 dtm1.insertRow(x1, new Object[] {uu1.get(x1).getsubject(), uu1.get(x1).getfirst(), uu1.get(x1).getsecond(),uu1.get(x1).getthird(), uu1.get(x1).getfourth(), uu1.get(x1).getave()});
//                // a6 = uu1.get(x1).getstuID();
//                 a7= uu1.get(x1).getsubID();
//                 jComboBox1.removeItem(uu1.get(x1).getsubject());
//                 
//                 }  
//             
//            if(jComboBox1.getSelectedItem() == null){
//            genAveTF.setEnabled(true);
//            jComboBox1.setEnabled(false);
//            jTextField2.setEnabled(false);
//            jTextField3.setEnabled(false);
//            jTextField4.setEnabled(false);
//            jTextField5.setEnabled(false);
//            jTextField7.setEnabled(false);
//            saveB.setEnabled(false);
//            saveAveB.setEnabled(true);
//            jButton1.setEnabled(true);
//            }else{
//            genAveTF.setEnabled(false);
//            jComboBox1.setEnabled(true);
//            jTextField2.setEnabled(true);
//            jTextField3.setEnabled(true);
//            jTextField4.setEnabled(true);
//            jTextField5.setEnabled(true);
//            jTextField7.setEnabled(true);
//            saveB.setEnabled(true);
//            saveAveB.setEnabled(false);
//            jButton1.setEnabled(false);
//            }
//           
//           
//                 
//            }catch (Exception e) {
//                JOptionPane.showMessageDialog(null, e.getMessage());
//                System.out.println(e);
//            }
           
           
    }
 
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new GradesS_Manage(/*mi, cUser*/).setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel bannerL;
    private javax.swing.JLabel currFld10;
    private javax.swing.JLabel dateL;
    private javax.swing.JTable gaGradeTbl;
    private javax.swing.JTable gaGradeTbl1;
    private javax.swing.JTextField genAveTF;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel78;
    private javax.swing.JScrollPane jScrollPane48;
    private javax.swing.JScrollPane jScrollPane49;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JButton logoutB;
    private javax.swing.JButton saveAveB;
    private javax.swing.JTextField searchT;
    private javax.swing.JLabel timeL;
    private javax.swing.JLabel usernameL;
    // End of variables declaration//GEN-END:variables
}
